from common.base import Base, By


class Curd(Base):
    """
    新增收获地址
    """

    def input_country(self, text):
        # 国家选择框
        self.drop_down_box((By.ID, 'selCountries_1'), text)

    def input_province(self, text):
        # 省选择框
        self.drop_down_box((By.ID, 'selProvinces_1'), text)

    def input_city(self, text):
        # 市选择框
        self.drop_down_box((By.ID, 'selCities_1'), text)

    def input_district(self, text):
        # 区选择框
        self.drop_down_box((By.ID, 'selDistricts_1'), text)

    def input_consignee(self, consignee):
        # 收件人
        self.find_element((By.ID, 'consignee_1')).send_keys(consignee)

    def input_email(self, email):
        # 邮件
        # 先清空再输入指定的邮件
        self.clear((By.ID, 'email_1'))
        self.find_element((By.ID, 'email_1')).send_keys(email)

    def input_address(self, address):
        # 收获地址
        self.find_element((By.ID, 'address_1')).send_keys(address)

    def input_phone(self, tel):
        # 电话
        self.find_element((By.ID, 'tel_1')).send_keys(tel)

    def input_submit(self):
        # 新增收获地址按键
        self.click((By.CLASS_NAME, 'bnt_blue_2'))

    def a_input_address(self, address):
        # 收货地址
        self.clear((By.ID, 'address_0'))
        self.find_element((By.ID, 'address_0')).send_keys(address)

    def a_input_phone(self, tel):
        # 电话号码
        self.clear((By.ID, 'tel_0'))
        self.find_element((By.ID, 'tel_0')).send_keys(tel)

    def input_confirm_modification(self):
        # 确认修改按键
        self.click((By.CLASS_NAME, 'bnt_blue_1'))

    def input_delete(self):
        # 删除指定收货地址
        self.click((By.XPATH, '/html/body/div[6]/div[2]/div/div/div/form[2]/table/tbody/tr[5]/td[2]/input[2]'))

    def input_alert(self):
        # 弹窗
        self.alert()
